<?php

namespace exception;

use support\exception\BusinessException;
use Webman\Http\Request;
use Webman\Http\Response;
use const support\ERROR;
use const support\RETCODE_MSGS;

class ErrorException extends BusinessException
{
    public function render(Request $request): ?Response
    {
        $code = $this->getCode()??ERROR;
        $msg=$this->getMessage()?:RETCODE_MSGS[$code];
        return buildFail($code,$msg);
    }
}